package edpool;

public class MyRandom 
{
	static private int counter = 0;
	
	/**
	 * Return the next psedo-random value in the range of module.
	 * @param module must be pow(2,X)-1 where X is 1-31. 
	 * @return next psedo-random
	 */
	static public int Next(int module, long threadId)
	{
		long id = threadId + counter++;
		int hash = (((int)(id ^ (id >>> 32))) ^ 0x811c9dc5) * 0x01000193;
		return hash & module;
	}

}
